package ru.reaperoq.inventory.navigation

import androidx.navigation.NavGraphBuilder
import androidx.navigation.compose.composable
import androidx.navigation.navigation
import ru.reaperoq.inventory.navigation.utils.LocalNavController
import ru.reaperoq.inventory.screens.auth.LoginScreen
import ru.reaperoq.inventory.screens.auth.RegisterScreen

fun NavGraphBuilder.authFlow(
    onAuth: () -> Unit
) {
    navigation(route = Screens.AuthFlow.route, startDestination = Screens.Login.route) {
        composable(Screens.Login.route) {
            val navController = LocalNavController.current
            LoginScreen(
                onLogin = onAuth,
                onRegisterClicked = {
                    navController.navigate(Screens.Register.route)
                }
            )
        }
        composable(Screens.Register.route) {
            val navController = LocalNavController.current
            RegisterScreen(
                onRegister = onAuth,
                onLoginClick = {
                    navController.navigate(Screens.Login.route)
                }
            )
        }
    }
}